<?php
require_once("userView.php");
require_once(CORE_DIR.'userModel.php');

class uploadAction extends authAction{

	function __construct(){
		$this->view = new userView();
	}

	public function run($get, $post, $viewtype) {
		parent::run($get,$post,$viewtype);
		
		$status = 0;
		$dirPath = "imagesuser/";
		if (isset($post["file"])){
			$folder = $dirPath.$post["userid"];
			if(!is_dir($folder)){
				mkdir( $folder, 0777 ); 
			}
			
			//$image = time().".".$post['ext'];
			$image = "img";
			
			if (file_put_contents($folder."/".$image, base64_decode($post["file"])))
			{
				$status = 1;
			}
		}		
		
		echo $post["userid"]."|".$image;
	}
}
?>